//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#include "engine.h"

static CGrafixEngine * g_pGrafixEngine = NULL;

EXTERN ECode GetLocalGrafixEngine(PInterface * ppGfxEngine)
{
    ECode ec = NOERROR;

    if (NULL == g_pGrafixEngine) {
        CGrafixEngine * pGfxEngine = NULL;
        pGfxEngine = new CGrafixEngine();
        if (NULL == pGfxEngine) {
            return E_OUT_OF_MEMORY;
        }
        ec = pGfxEngine->constructor();
        if (FAILED(ec)) {
            delete pGfxEngine;
            return E_OUT_OF_MEMORY;
        }
        pGfxEngine->AddRef();
        g_pGrafixEngine = pGfxEngine;
    }
    else {
        g_pGrafixEngine->AddRef();
    }

    *ppGfxEngine = (PInterface)g_pGrafixEngine;
    return ec;
}

